package cn.zcy.controller;

import cn.zcy.domain.Student;
import cn.zcy.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 返回json格式数据，使用的是springmvc内置的jackson
 */
@Controller
public class JsonController {
    @RequestMapping("/hello")
    @ResponseBody
    public Student hello(){
        Student student=new Student(1,"张三");
        return student;
    }

    @PostMapping("/json")
    @ResponseBody
    public Student json(@RequestBody String anme){
        System.out.println("anme = " + anme);
        Student student=new Student();
        student.setId(1);
        student.setUsername("李四");
        return student;
    }

    @PostMapping("/jsons")
    @ResponseBody
    public Student json(@RequestBody User user){
        System.out.println("user = " + user);
        Student student=new Student();
        student.setId(1);
        student.setUsername("李四");
        return student;
    }
}
